<template>
  <div id="app">
    <h1>{{ title }} - {{ count }}</h1>
    <input type="text" :value="count" @input="handle" />
    <Son1></Son1>
    <hr />
    <Son2></Son2>
  </div>
</template>

<script>
import { mapState } from "vuex";
import Son1 from "../components/05/Son1.vue";
import Son2 from "../components/05/Son2.vue";
export default {
  name: "app",
  created() {
    console.log(this.$store.state.count);
  },
  computed: {
    ...mapState(["count", "title"]),
  },
  data: function () {
    return {};
  },
  methods: {
    handle(e) {
      this.$store.commit("changeCount",+e.target.value);
    },
  },
  components: {
    Son1,
    Son2,
  },
};
</script>

<style>
#app {
  width: 600px;
  margin: 20px auto;
  border: 3px solid #ccc;
  border-radius: 3px;
  padding: 10px;
}
</style>
